{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e0984b06-7514-4785-9e4c-df41f445b51e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-06-01T18:59:18.365596Z",
     "iopub.status.busy": "2024-06-01T18:59:18.365090Z",
     "iopub.status.idle": "2024-06-01T18:59:24.759174Z",
     "shell.execute_reply": "2024-06-01T18:59:24.758773Z",
     "shell.execute_reply.started": "2024-06-01T18:59:18.365580Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Folder VAE_experiment/result has been compressed to VAE_experiment/result.zip\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import zipfile\n",
    "\n",
    "# 设置文件夹路径\n",
    "folder_path = 'VAE_experiment/result'\n",
    "# 设置压缩文件的名称\n",
    "zip_filename = 'VAE_experiment/result.zip'\n",
    "\n",
    "# 创建压缩文件\n",
    "with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:\n",
    "    for root, dirs, files in os.walk(folder_path):\n",
    "        for file in files:\n",
    "            # 将文件添加到压缩文件中\n",
    "            zipf.write(os.path.join(root, file),\n",
    "                       os.path.relpath(os.path.join(root, file), \n",
    "                                       os.path.join(folder_path, '..')))\n",
    "\n",
    "print(f'Folder {folder_path} has been compressed to {zip_filename}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f10f978a-4044-49f1-b76f-c4a422ce4670",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
